﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:viewModels="clr-namespace:EstimateTracker.ViewModels"
                    >
    
    <DataTemplate DataType="{x:Type viewModels:TimerTabViewModel}">
        <Grid>

            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="10*"/>
                <RowDefinition Height="75*"/>
                <RowDefinition Height="15*"/>
            </Grid.RowDefinitions>

            <ContentControl Grid.Row="0" Grid.ColumnSpan="2" Content="{Binding ProjectViewModel}"/>

            <Button Content="Add Project" Grid.Row="0" Grid.ColumnSpan="2" Width="75" Margin="435,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" Command="{Binding AddProject}" CommandParameter="{x:Reference ProjectText}"></Button>
            <TextBox x:Name="ProjectText" Text="{Binding ProjectName,Mode=TwoWay}" Width="210" Grid.Row="0" Grid.ColumnSpan="2" Margin="220,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" ></TextBox>
            
            <Button Content="Add Activity" Grid.Row="0" Grid.ColumnSpan="2" Width="75" Margin="730,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" Command="{Binding AddActivity}" CommandParameter="{x:Reference ProjectText}"></Button>
            <TextBox Text="{Binding ActivityName,Mode=TwoWay}" Width="210" Grid.Row="0" Grid.ColumnSpan="2" Margin="515,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Center" ></TextBox>
            
            <Label Content="Name" Width="50" Grid.Row="2" Margin="0,10,0,0" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Top"></Label>
            <TextBox Text="{Binding TaskName,Mode=TwoWay}" Width="210" Grid.Row="2" Grid.Column="0" Margin="55,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" ></TextBox>
            
            <Label Content="Estimate:" Margin="0,40,0,0" Width="55" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Top"></Label>
            <TextBox Text="{Binding TaskEstimate,Mode=TwoWay}" Width="210" Grid.Row="2" Grid.Column="0" Margin="55,40,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" ></TextBox>

            <Button Content="Add Task" Grid.Row="2" Grid.ColumnSpan="2" Width="75" Margin="275,10,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding AddTask}" CommandParameter="{x:Reference ProjectText}"></Button>

            <Label Grid.Row="2" Grid.Column="1" Content="{Binding TaskHours}" ContentStringFormat="{}Hours spent on task: {0}" HorizontalAlignment="Left" VerticalAlignment="Top"></Label>
            <Label Grid.Row="2" Margin="80,35,0,0" Grid.Column="1" Content="{Binding Time}" ContentStringFormat="{}{0:hh\:mm}" HorizontalAlignment="Left" VerticalAlignment="Top"></Label>
            <Button Width="75" Grid.Row="2" Grid.Column="1" Margin="0,35,0,0" Content="{Binding TimerLabel}" Command="{Binding NotifyTimer}" HorizontalAlignment="Left" VerticalAlignment="Top"></Button>
            
            <ContentControl Grid.Row="1" Grid.Column="0" Content="{Binding ActivityViewModel}"/>
            <ContentControl Grid.Row="1" Grid.Column="1" Content="{Binding TaskViewModel}"/>

        </Grid>
    </DataTemplate>
    
    <DataTemplate DataType="{x:Type viewModels:ActivityViewModel}">
        <DataGrid  AutoGenerateColumns="False" ColumnWidth="100*" ItemsSource="{Binding Activities}" IsReadOnly="True" SelectedItem="{Binding SelectedActivity,Mode=TwoWay}">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Name}" Header="Activity"/>
            </DataGrid.Columns>
        </DataGrid>
    </DataTemplate>
    
    <DataTemplate DataType="{x:Type viewModels:TaskViewModel}">
        <DataGrid Grid.Row="1" Grid.Column="1" AutoGenerateColumns="False" ColumnWidth="100*" ItemsSource="{Binding Tasks}" IsReadOnly="True" SelectedItem="{Binding SelectedTask,Mode=TwoWay}">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Name}" Header="Task"/>
                <DataGridTextColumn Binding="{Binding EstimatedHours}" Header="Estimate"/>
            </DataGrid.Columns>
        </DataGrid>
    </DataTemplate>
    
    <DataTemplate DataType="{x:Type viewModels:ProjectViewModel}">
        <ComboBox ItemsSource="{Binding Projects}" Width="210" SelectedItem="{Binding SelectedProject,Mode=TwoWay}" Grid.Row="0" Grid.ColumnSpan="2" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="5,0,0,0">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Name}"></TextBlock>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
    </DataTemplate>
    
</ResourceDictionary>